package jp.bsws.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import jp.bsws.common.BSWSUtils;
import jp.bsws.model.UriageSyosaiModel;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class GekkeiHyoDao {
    private static GekkeiHyoDao gekkeiHyoDao = new GekkeiHyoDao();

    /** ログです。 */
	private static Log log = LogFactory.getLog(GekkeiHyoDao.class);

	/**
	 * コンストラクタです。
	 */
    // Singletonパターンで単一のインスタンスを取得
    public static GekkeiHyoDao getInstance(){
    	return gekkeiHyoDao;
    }

	/**
     * 集計情報取得
     * 引数のPKがあれば条件とする。
     */
	public List<UriageSyosaiModel> getGekkeiHyoJoho(Connection con, String pkGroupCod, String pkTenpoCod, String pkJugyoinCod, Integer intUriageYmdFrom, Integer intUriageYmdTo) throws Exception{

		ArrayList<UriageSyosaiModel> resultList = new ArrayList<UriageSyosaiModel>();

		//検索条件の作成
		String where = "";
		ArrayList<String> whereList = new ArrayList<String>();
		if( BSWSUtils.isNotBlankNull(pkGroupCod)){
			where += BSWSUtils.getWhereAnd(where) + " GROUP_COD = ? ";
			whereList.add(pkGroupCod);
		}
		if( BSWSUtils.isNotBlankNull(pkTenpoCod)){
			where += BSWSUtils.getWhereAnd(where) + " TENPO_COD = ? ";
			whereList.add(pkTenpoCod);
		}
		if( BSWSUtils.isNotBlankNull(pkJugyoinCod)){
			where += BSWSUtils.getWhereAnd(where) + " JUGYOIN_COD = ? ";
			whereList.add(pkJugyoinCod);
		}
		String whereYmd = "";
		Integer fromYmd = 0;
		Integer toYmd = 99991231;
		if( BSWSUtils.isNotZeroNull(intUriageYmdFrom) || BSWSUtils.isNotZeroNull(intUriageYmdTo)){
			whereYmd = BSWSUtils.getWhereAnd(where)  + "  H.YMD BETWEEN ? AND ? ";
			if(BSWSUtils.isNotZeroNull(intUriageYmdFrom) && BSWSUtils.isNotZeroNull(intUriageYmdTo)){
				fromYmd = intUriageYmdFrom;
				toYmd = intUriageYmdTo;
			}else if(BSWSUtils.isNotZeroNull(intUriageYmdFrom) && BSWSUtils.isZeroNull(intUriageYmdTo)){
				fromYmd = intUriageYmdFrom;
			}else if(BSWSUtils.isZeroNull(intUriageYmdFrom) && BSWSUtils.isNotZeroNull(intUriageYmdTo)){
				toYmd = intUriageYmdTo;
			}
		}
		String groupBy = " GROUP BY H.YMD ";
		String orderBy = " ORDER BY H.YMD ";
		PreparedStatement stmt = con.prepareStatement(SQL_GEKKEI_HYO + where + whereYmd + groupBy + orderBy);
		int cnt = 0;
		for(int i = 0; i < whereList.size(); i++){
			stmt.setString(i + 1, (String)whereList.get(i));
			cnt++ ;
		}
		if(BSWSUtils.isNotBlankNull(whereYmd)){
			stmt.setInt(cnt + 1, fromYmd);
			stmt.setInt(cnt + 2, toYmd);
		}

		ResultSet rs = stmt.executeQuery();

		UriageSyosaiModel uriageSyosaiModel = null;
		while(rs.next()){
			uriageSyosaiModel = new UriageSyosaiModel();
			Integer intUriageYmd = rs.getInt("URIAGE_YMD");
			Integer intShinkiSu = rs.getInt("SHINKI_SU");
			Integer intSairaiSu = rs.getInt("SAIRAI_SU");
			Integer intShimeiSu = rs.getInt("SHIMEI_SU");
			Integer intNyukyakuSu = rs.getInt("NYUKYAKU_SU");
			Integer intHontaiKin = rs.getInt("HONTAI_KIN");
			Integer intSyohizeiKbn = rs.getInt("SYOHIZEI_KIN");
			Integer intUriageGokeiKin = rs.getInt("URIAGE_GOKEI_KIN");
			Integer intTankaKin = rs.getInt("TANKA_KIN");
			Integer intHosyuGokeiKin = rs.getInt("HOSYU_GOKEI_KIN");
			String strRaitenYoin1Cod = rs.getString("RAITEN_YOIN1_COD");
			Integer intRaitenYoin1Su = rs.getInt("RAITEN_YOIN1_SU");
			String strRaitenYoin2Cod = rs.getString("RAITEN_YOIN2_COD");
			Integer intRaitenYoin2Su = rs.getInt("RAITEN_YOIN2_SU");
			String strRaitenYoin3Cod = rs.getString("RAITEN_YOIN3_COD");
			Integer intRaitenYoin3Su = rs.getInt("RAITEN_YOIN3_SU");
			String strRaitenYoin4Cod = rs.getString("RAITEN_YOIN4_COD");
			Integer intRaitenYoin4Su = rs.getInt("RAITEN_YOIN4_SU");
			String strRaitenYoin5Cod = rs.getString("RAITEN_YOIN5_COD");
			Integer intRaitenYoin5Su = rs.getInt("RAITEN_YOIN5_SU");
			String strRaitenYoin6Cod = rs.getString("RAITEN_YOIN6_COD");
			Integer intRaitenYoin6Su = rs.getInt("RAITEN_YOIN6_SU");
			String strRaitenYoin7Cod = rs.getString("RAITEN_YOIN7_COD");
			Integer intRaitenYoin7Su = rs.getInt("RAITEN_YOIN7_SU");
			String strRaitenYoin8Cod = rs.getString("RAITEN_YOIN8_COD");
			Integer intRaitenYoin8Su = rs.getInt("RAITEN_YOIN8_SU");
			String strUriageShubetsu1Cod = rs.getString("URIAGE_SHUBETSU1_COD");
			Integer intUriageShubetsu1Kin = rs.getInt("URIAGE_SHUBETSU1_KIN");
			String strUriageShubetsu2Cod = rs.getString("URIAGE_SHUBETSU2_COD");
			Integer intUriageShubetsu2Kin = rs.getInt("URIAGE_SHUBETSU2_KIN");
			String strUriageShubetsu3Cod = rs.getString("URIAGE_SHUBETSU3_COD");
			Integer intUriageShubetsu3Kin = rs.getInt("URIAGE_SHUBETSU3_KIN");
			String strUriageShubetsu4Cod = rs.getString("URIAGE_SHUBETSU4_COD");
			Integer intUriageShubetsu4Kin = rs.getInt("URIAGE_SHUBETSU4_KIN");
			String strUriageShubetsu5Cod = rs.getString("URIAGE_SHUBETSU5_COD");
			Integer intUriageShubetsu5Kin = rs.getInt("URIAGE_SHUBETSU5_KIN");
			String strUriageShubetsu6Cod = rs.getString("URIAGE_SHUBETSU6_COD");
			Integer intUriageShubetsu6Kin = rs.getInt("URIAGE_SHUBETSU6_KIN");
			String strUriageShubetsu7Cod = rs.getString("URIAGE_SHUBETSU7_COD");
			Integer intUriageShubetsu7Kin = rs.getInt("URIAGE_SHUBETSU7_KIN");
			String strUriageShubetsu8Cod = rs.getString("URIAGE_SHUBETSU8_COD");
			Integer intUriageShubetsu8Kin = rs.getInt("URIAGE_SHUBETSU8_KIN");
			String strShiharaiHoho1Cod = rs.getString("SHIHARAI_HOHO1_COD");
			Integer intShiharaiHoho1Kin = rs.getInt("SHIHARAI_HOHO1_KIN");
			String strShiharaiHoho2Cod = rs.getString("SHIHARAI_HOHO2_COD");
			Integer intShiharaiHoho2Kin = rs.getInt("SHIHARAI_HOHO2_KIN");
			String strShiharaiHoho3Cod = rs.getString("SHIHARAI_HOHO3_COD");
			Integer intShiharaiHoho3Kin = rs.getInt("SHIHARAI_HOHO3_KIN");
			String strShiharaiHoho4Cod = rs.getString("SHIHARAI_HOHO4_COD");
			Integer intShiharaiHoho4Kin = rs.getInt("SHIHARAI_HOHO4_KIN");
			String strShiharaiHoho5Cod = rs.getString("SHIHARAI_HOHO5_COD");
			Integer intShiharaiHoho5Kin = rs.getInt("SHIHARAI_HOHO5_KIN");
			String strHosyuShubetsu1Cod = rs.getString("HOSYU_SHUBETSU1_COD");
			Integer intHosyuShubetsu1Kin = rs.getInt("HOSYU_SHUBETSU1_KIN");
			String strHosyuShubetsu2Cod = rs.getString("HOSYU_SHUBETSU2_COD");
			Integer intHosyuShubetsu2Kin = rs.getInt("HOSYU_SHUBETSU2_KIN");
			String strHosyuShubetsu3Cod = rs.getString("HOSYU_SHUBETSU3_COD");
			Integer intHosyuShubetsu3Kin = rs.getInt("HOSYU_SHUBETSU3_KIN");
			String strHosyuShubetsu4Cod = rs.getString("HOSYU_SHUBETSU4_COD");
			Integer intHosyuShubetsu4Kin = rs.getInt("HOSYU_SHUBETSU4_KIN");
			String strHosyuShubetsu5Cod = rs.getString("HOSYU_SHUBETSU5_COD");
			Integer intHosyuShubetsu5Kin = rs.getInt("HOSYU_SHUBETSU5_KIN");
			String strHosyuShubetsu6Cod = rs.getString("HOSYU_SHUBETSU6_COD");
			Integer intHosyuShubetsu6Kin = rs.getInt("HOSYU_SHUBETSU6_KIN");
			String strHosyuShubetsu7Cod = rs.getString("HOSYU_SHUBETSU7_COD");
			Integer intHosyuShubetsu7Kin = rs.getInt("HOSYU_SHUBETSU7_KIN");
			String strHosyuShubetsu8Cod = rs.getString("HOSYU_SHUBETSU8_COD");
			Integer intHosyuShubetsu8Kin = rs.getInt("HOSYU_SHUBETSU8_KIN");

//			uriageSyosaiModel.setIntUriageYmd(intUriageYmd);
//			uriageSyosaiModel.setIntShinkiSu(intShinkiSu);
//			uriageSyosaiModel.setIntSairaiSu(intSairaiSu);
//			uriageSyosaiModel.setIntShimeiSu(intShimeiSu);
//			uriageSyosaiModel.setIntNyukyakuSu(intNyukyakuSu);
//			uriageSyosaiModel.setIntHontaiKin(intHontaiKin);
//			uriageSyosaiModel.setIntSyohizeiKin(intSyohizeiKbn);
//			uriageSyosaiModel.setIntUriageGokeiKin(intUriageGokeiKin);
//			uriageSyosaiModel.setIntTankaKin(intTankaKin);
//			uriageSyosaiModel.setIntHosyuGokeiKin(intHosyuGokeiKin);
//			uriageSyosaiModel.setStrRaitenYoin1Cod(strRaitenYoin1Cod);
//			uriageSyosaiModel.setIntRaitenYoin1Su(intRaitenYoin1Su);
//			uriageSyosaiModel.setStrRaitenYoin2Cod(strRaitenYoin2Cod);
//			uriageSyosaiModel.setIntRaitenYoin2Su(intRaitenYoin2Su);
//			uriageSyosaiModel.setStrRaitenYoin3Cod(strRaitenYoin3Cod);
//			uriageSyosaiModel.setIntRaitenYoin3Su(intRaitenYoin3Su);
//			uriageSyosaiModel.setStrRaitenYoin4Cod(strRaitenYoin4Cod);
//			uriageSyosaiModel.setIntRaitenYoin4Su(intRaitenYoin4Su);
//			uriageSyosaiModel.setStrRaitenYoin5Cod(strRaitenYoin5Cod);
//			uriageSyosaiModel.setIntRaitenYoin5Su(intRaitenYoin5Su);
//			uriageSyosaiModel.setStrRaitenYoin6Cod(strRaitenYoin6Cod);
//			uriageSyosaiModel.setIntRaitenYoin6Su(intRaitenYoin6Su);
//			uriageSyosaiModel.setStrRaitenYoin7Cod(strRaitenYoin7Cod);
//			uriageSyosaiModel.setIntRaitenYoin7Su(intRaitenYoin7Su);
//			uriageSyosaiModel.setStrRaitenYoin8Cod(strRaitenYoin8Cod);
//			uriageSyosaiModel.setIntRaitenYoin8Su(intRaitenYoin8Su);
//			uriageSyosaiModel.setStrUriageShubetsu1Cod(strUriageShubetsu1Cod);
//			uriageSyosaiModel.setIntUriageShubetsu1Kin(intUriageShubetsu1Kin);
//			uriageSyosaiModel.setStrUriageShubetsu2Cod(strUriageShubetsu2Cod);
//			uriageSyosaiModel.setIntUriageShubetsu2Kin(intUriageShubetsu2Kin);
//			uriageSyosaiModel.setStrUriageShubetsu3Cod(strUriageShubetsu3Cod);
//			uriageSyosaiModel.setIntUriageShubetsu3Kin(intUriageShubetsu3Kin);
//			uriageSyosaiModel.setStrUriageShubetsu4Cod(strUriageShubetsu4Cod);
//			uriageSyosaiModel.setIntUriageShubetsu4Kin(intUriageShubetsu4Kin);
//			uriageSyosaiModel.setStrUriageShubetsu5Cod(strUriageShubetsu5Cod);
//			uriageSyosaiModel.setIntUriageShubetsu5Kin(intUriageShubetsu5Kin);
//			uriageSyosaiModel.setStrUriageShubetsu6Cod(strUriageShubetsu6Cod);
//			uriageSyosaiModel.setIntUriageShubetsu6Kin(intUriageShubetsu6Kin);
//			uriageSyosaiModel.setStrUriageShubetsu7Cod(strUriageShubetsu7Cod);
//			uriageSyosaiModel.setIntUriageShubetsu7Kin(intUriageShubetsu7Kin);
//			uriageSyosaiModel.setStrUriageShubetsu8Cod(strUriageShubetsu8Cod);
//			uriageSyosaiModel.setIntUriageShubetsu8Kin(intUriageShubetsu8Kin);
//			uriageSyosaiModel.setStrShiharaiHoho1Cod(strShiharaiHoho1Cod);
//			uriageSyosaiModel.setIntShiharaiHoho1Kin(intShiharaiHoho1Kin);
//			uriageSyosaiModel.setStrShiharaiHoho2Cod(strShiharaiHoho2Cod);
//			uriageSyosaiModel.setIntShiharaiHoho2Kin(intShiharaiHoho2Kin);
//			uriageSyosaiModel.setStrShiharaiHoho3Cod(strShiharaiHoho3Cod);
//			uriageSyosaiModel.setIntShiharaiHoho3Kin(intShiharaiHoho3Kin);
//			uriageSyosaiModel.setStrShiharaiHoho4Cod(strShiharaiHoho4Cod);
//			uriageSyosaiModel.setIntShiharaiHoho4Kin(intShiharaiHoho4Kin);
//			uriageSyosaiModel.setStrShiharaiHoho5Cod(strShiharaiHoho5Cod);
//			uriageSyosaiModel.setIntShiharaiHoho5Kin(intShiharaiHoho5Kin);
//			uriageSyosaiModel.setStrHosyuShubetsu1Cod(strHosyuShubetsu1Cod);
//			uriageSyosaiModel.setIntHosyuShubetsu1Kin(intHosyuShubetsu1Kin);
//			uriageSyosaiModel.setStrHosyuShubetsu2Cod(strHosyuShubetsu2Cod);
//			uriageSyosaiModel.setIntHosyuShubetsu2Kin(intHosyuShubetsu2Kin);
//			uriageSyosaiModel.setStrHosyuShubetsu3Cod(strHosyuShubetsu3Cod);
//			uriageSyosaiModel.setIntHosyuShubetsu3Kin(intHosyuShubetsu3Kin);
//			uriageSyosaiModel.setStrHosyuShubetsu4Cod(strHosyuShubetsu4Cod);
//			uriageSyosaiModel.setIntHosyuShubetsu4Kin(intHosyuShubetsu4Kin);
//			uriageSyosaiModel.setStrHosyuShubetsu5Cod(strHosyuShubetsu5Cod);
//			uriageSyosaiModel.setIntHosyuShubetsu5Kin(intHosyuShubetsu5Kin);
//			uriageSyosaiModel.setStrHosyuShubetsu6Cod(strHosyuShubetsu6Cod);
//			uriageSyosaiModel.setIntHosyuShubetsu6Kin(intHosyuShubetsu6Kin);
//			uriageSyosaiModel.setStrHosyuShubetsu7Cod(strHosyuShubetsu7Cod);
//			uriageSyosaiModel.setIntHosyuShubetsu7Kin(intHosyuShubetsu7Kin);
//			uriageSyosaiModel.setStrHosyuShubetsu8Cod(strHosyuShubetsu8Cod);
//			uriageSyosaiModel.setIntHosyuShubetsu8Kin(intHosyuShubetsu8Kin);
			resultList.add(uriageSyosaiModel);
		}

		rs.close();
		stmt.close();
		con.close();

		return resultList;
	}

	private final String SQL_GEKKEI_HYO =
	" SELECT " +
	"     H.YMD URIAGE_YMD" +
	"    ,SUM(S.SHINKI_SU) SHINKI_SU " +
	"    ,SUM(S.SAIRAI_SU) SAIRAI_SU " +
	"    ,SUM(S.SHIMEI_SU) SHIMEI_SU " +
	"    ,SUM(S.NYUKYAKU_SU) NYUKYAKU_SU " +
	"    ,SUM(S.HONTAI_KIN) HONTAI_KIN " +
	"    ,SUM(S.SYOHIZEI_KIN) SYOHIZEI_KIN " +
	"    ,SUM(S.URIAGE_GOKEI_KIN) URIAGE_GOKEI_KIN " +
	"    ,SUM(S.TANKA_KIN) TANKA_KIN " +
	"    ,SUM(S.HOSYU_GOKEI_KIN) HOSYU_GOKEI_KIN " +
	"    ,SUM(S.RAITEN_YOIN1_COD) RAITEN_YOIN1_COD " +
	"    ,SUM(S.RAITEN_YOIN1_SU) RAITEN_YOIN1_SU " +
	"    ,SUM(S.RAITEN_YOIN2_COD) RAITEN_YOIN2_COD " +
	"    ,SUM(S.RAITEN_YOIN2_SU) RAITEN_YOIN2_SU " +
	"    ,SUM(S.RAITEN_YOIN3_COD) RAITEN_YOIN3_COD " +
	"    ,SUM(S.RAITEN_YOIN3_SU) RAITEN_YOIN3_SU " +
	"    ,SUM(S.RAITEN_YOIN4_COD) RAITEN_YOIN4_COD " +
	"    ,SUM(S.RAITEN_YOIN4_SU) RAITEN_YOIN4_SU " +
	"    ,SUM(S.RAITEN_YOIN5_COD) RAITEN_YOIN5_COD " +
	"    ,SUM(S.RAITEN_YOIN5_SU) RAITEN_YOIN5_SU " +
	"    ,SUM(S.RAITEN_YOIN6_COD) RAITEN_YOIN6_COD " +
	"    ,SUM(S.RAITEN_YOIN6_SU) RAITEN_YOIN6_SU " +
	"    ,SUM(S.RAITEN_YOIN7_COD) RAITEN_YOIN7_COD " +
	"    ,SUM(S.RAITEN_YOIN7_SU) RAITEN_YOIN7_SU " +
	"    ,SUM(S.RAITEN_YOIN8_COD) RAITEN_YOIN8_COD " +
	"    ,SUM(S.RAITEN_YOIN8_SU) RAITEN_YOIN8_SU " +
	"    ,SUM(S.URIAGE_SHUBETSU1_COD) URIAGE_SHUBETSU1_COD " +
	"    ,SUM(S.URIAGE_SHUBETSU1_KIN) URIAGE_SHUBETSU1_KIN " +
	"    ,SUM(S.URIAGE_SHUBETSU2_COD) URIAGE_SHUBETSU2_COD " +
	"    ,SUM(S.URIAGE_SHUBETSU2_KIN) URIAGE_SHUBETSU2_KIN " +
	"    ,SUM(S.URIAGE_SHUBETSU3_COD) URIAGE_SHUBETSU3_COD " +
	"    ,SUM(S.URIAGE_SHUBETSU3_KIN) URIAGE_SHUBETSU3_KIN " +
	"    ,SUM(S.URIAGE_SHUBETSU4_COD) URIAGE_SHUBETSU4_COD " +
	"    ,SUM(S.URIAGE_SHUBETSU4_KIN) URIAGE_SHUBETSU4_KIN " +
	"    ,SUM(S.URIAGE_SHUBETSU5_COD) URIAGE_SHUBETSU5_COD " +
	"    ,SUM(S.URIAGE_SHUBETSU5_KIN) URIAGE_SHUBETSU5_KIN " +
	"    ,SUM(S.URIAGE_SHUBETSU6_COD) URIAGE_SHUBETSU6_COD " +
	"    ,SUM(S.URIAGE_SHUBETSU6_KIN) URIAGE_SHUBETSU6_KIN " +
	"    ,SUM(S.URIAGE_SHUBETSU7_COD) URIAGE_SHUBETSU7_COD " +
	"    ,SUM(S.URIAGE_SHUBETSU7_KIN) URIAGE_SHUBETSU7_KIN " +
	"    ,SUM(S.URIAGE_SHUBETSU8_COD) URIAGE_SHUBETSU8_COD " +
	"    ,SUM(S.URIAGE_SHUBETSU8_KIN) URIAGE_SHUBETSU8_KIN " +
	"    ,SUM(S.SHIHARAI_HOHO1_COD) SHIHARAI_HOHO1_COD " +
	"    ,SUM(S.SHIHARAI_HOHO1_KIN) SHIHARAI_HOHO1_KIN " +
	"    ,SUM(S.SHIHARAI_HOHO2_COD) SHIHARAI_HOHO2_COD " +
	"    ,SUM(S.SHIHARAI_HOHO2_KIN) SHIHARAI_HOHO2_KIN " +
	"    ,SUM(S.SHIHARAI_HOHO3_COD) SHIHARAI_HOHO3_COD " +
	"    ,SUM(S.SHIHARAI_HOHO3_KIN) SHIHARAI_HOHO3_KIN " +
	"    ,SUM(S.SHIHARAI_HOHO4_COD) SHIHARAI_HOHO4_COD " +
	"    ,SUM(S.SHIHARAI_HOHO4_KIN) SHIHARAI_HOHO4_KIN " +
	"    ,SUM(S.SHIHARAI_HOHO5_COD) SHIHARAI_HOHO5_COD " +
	"    ,SUM(S.SHIHARAI_HOHO5_KIN) SHIHARAI_HOHO5_KIN " +
	"    ,SUM(S.HOSYU_SHUBETSU1_COD) HOSYU_SHUBETSU1_COD " +
	"    ,SUM(S.HOSYU_SHUBETSU1_KIN) HOSYU_SHUBETSU1_KIN " +
	"    ,SUM(S.HOSYU_SHUBETSU2_COD) HOSYU_SHUBETSU2_COD " +
	"    ,SUM(S.HOSYU_SHUBETSU2_KIN) HOSYU_SHUBETSU2_KIN " +
	"    ,SUM(S.HOSYU_SHUBETSU3_COD) HOSYU_SHUBETSU3_COD " +
	"    ,SUM(S.HOSYU_SHUBETSU3_KIN) HOSYU_SHUBETSU3_KIN " +
	"    ,SUM(S.HOSYU_SHUBETSU4_COD) HOSYU_SHUBETSU4_COD " +
	"    ,SUM(S.HOSYU_SHUBETSU4_KIN) HOSYU_SHUBETSU4_KIN " +
	"    ,SUM(S.HOSYU_SHUBETSU5_COD) HOSYU_SHUBETSU5_COD " +
	"    ,SUM(S.HOSYU_SHUBETSU5_KIN) HOSYU_SHUBETSU5_KIN " +
	"    ,SUM(S.HOSYU_SHUBETSU6_COD) HOSYU_SHUBETSU6_COD " +
	"    ,SUM(S.HOSYU_SHUBETSU6_KIN) HOSYU_SHUBETSU6_KIN " +
	"    ,SUM(S.HOSYU_SHUBETSU7_COD) HOSYU_SHUBETSU7_COD " +
	"    ,SUM(S.HOSYU_SHUBETSU7_KIN) HOSYU_SHUBETSU7_KIN " +
	"    ,SUM(S.HOSYU_SHUBETSU8_COD) HOSYU_SHUBETSU8_COD " +
	"    ,SUM(S.HOSYU_SHUBETSU8_KIN) HOSYU_SHUBETSU8_KIN " +
	" FROM " +
	"     M_HIDUKE H" +
	"     LEFT OUTER JOIN T_URIAGE_SYOSAI S ON (" +
	"         H.YMD = S.URIAGE_YMD " +
	"     ) ";

}